<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('trip_query_history', function (Blueprint $table) {
            $table->id();
            $table->uuid('user_id')->comment('用户id');
            $table->tinyInteger('trip_type')->comment('行程类型 1 火车 2 飞机 3 酒店 4 打车');
            $table->string('from_type')->default('')->comment('出发地类型 如酒店可能没有 要求出发地');
            $table->string('from_code')->default('')->comment('出发地编码');
            $table->string('to_type')->comment('目的地类型');
            $table->string('to_code')->comment('目的地编码');
            $table->string('from_name')->default('')->comment('出发地');
            $table->string('from_name_uy')->default('')->default('')->comment('出发地维语');
            $table->string('to_name')->comment('目的地');
            $table->string('to_name_uy')->default('')->comment('目的地维语');
            $table->timestamps();
            $table->index(['user_id', 'trip_type', 'updated_at'], 'idx_user_type');
            $table->index(['user_id', 'from_code', 'to_code'], 'idx_user_code');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('trip_query_history');
    }
};
